package com.wbt.huawei.c20220717;

import java.util.Arrays;
import java.util.Scanner;

public class HJ18 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ipAndMask = new String[2];
        int A = 0,B = 0,C = 0,D =0,E = 0,errIpOrMask = 0,privateIp = 0;
        while (sc.hasNextLine()){
            ipAndMask = sc.nextLine().split("\\~");
            int[] ipArr = Arrays.asList(ipAndMask[0].split("\\.")).stream().mapToInt(Integer::valueOf).toArray();
            int[] maskArr = Arrays.asList(ipAndMask[1].split("\\.")).stream().mapToInt(Integer::valueOf).toArray();
            //类似于【0.*.*.*】和【127.*.*.*】忽略，这个条件要放在最前面，否则错误掩码会统计多
            if (ipArr.length != 4 || maskArr.length != 4) {
                errIpOrMask ++;
            }

            if(ipArr[0] == 0 || ipArr[0] ==127 ){
                continue;//跳过
            }

            for (int i = 0; i < 4; i++) {
                if (ipArr[i] < 0 || ipArr[i] > 255 || maskArr[i] < 0 || maskArr[i] > 255) {
                    errIpOrMask ++;
                }
            }

            if(isValidMask(ipAndMask[0])){

            }

            if (ipArr[0] >= 240 && ipArr[0] <= 255) {// e类地址
                E++;
            } else if (ipArr[0] >= 224) {// d类地址
                D++;
            } else if (ipArr[0] >= 192) {// c类地址
                C++;
            } else if (ipArr[0] >= 128) {// b类地址
                B++;
            } else if (ipArr[0] >= 1 && ipArr[0] <= 126) {// a类地址
                A++;
            }
            if (ipArr[0] == 10
                    || (ipArr[0] == 172 && ipArr[1] >= 16 && ipArr[1] <= 31)
                    || (ipArr[0] == 192 && ipArr[1] == 168)) {// 私有地址
                privateIp++;
            }

        }
        System.out.println(A + " " + B + " " + C + " " + D + " " + E + " " + errIpOrMask + " " + privateIp);
    }


    public static boolean isValidMask(String mask){

        String[] maskTable = mask.split("\\.");
        //mask转为32位2进制字符串
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<maskTable.length;i++){
            maskTable[i] = Integer.toBinaryString(Integer.parseInt(maskTable[i]));
            if(maskTable[i].length() < 8){//不足8位补齐0
                for(int j=0;j < 8- maskTable[i].length();j++){
                    sb.append("0");//补完零
                }
                sb.append(maskTable[i]);//再添加转换的2进制串
            }else{
                sb.append(maskTable[i]);//刚好8位直接添加，因为之前已经判断过ip的有效性，所以不可能超过8位
            }
        }
        //最后一个1在第一个0之前，有效，否则无效
        return sb.toString().lastIndexOf("1") < sb.toString().indexOf("0");
    }

    public static boolean isValidIp(String ip){
        String[] ipTable = ip.split("\\.");
        if(ipTable.length != 4){
            return false;
        }
        for(String s : ipTable){
            if(Integer.parseInt(s) < 0 || Integer.parseInt(s) > 255){
                return false;
            }
        }
        return true;
    }
}
